﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WcfMasterSlaveElectionService
{
    /// <summary>
    /// Interface of the MasterSlaveElectionService.
    /// </summary>
    [ServiceContract(Namespace = "uri:MasterSlaveElection//2011/1")]
    public interface IMasterElectionService
    {
        [OperationContract(IsOneWay = true)]
        void BroadcastVictory(string newMaster);

        [OperationContract]
        bool IsMaster();

        [OperationContract(IsOneWay = true)]
        void BecomeMaster();

        [OperationContract()]
        RequestMasterElectionIdResult RequestMasterElectionId();
    }

    [DataContract(Namespace = "uri:MasterSlaveElection//2011/1")]
    public class RequestMasterElectionIdResult : IExtensibleDataObject
    {
        [DataMember(Order = 1, IsRequired = true, EmitDefaultValue = false)]
        public string Id { get; set; }

        [DataMember(Order = 2)]
        public string Master { get; set; }


        [DataMember(Order = 3)]
        public bool IsRunningElection { get; set; }
        
        public ExtensionDataObject ExtensionData { get; set; }
    }
}
